package cur.tool.dao;

import cur.nature.framework.core.util.StringUtil;
import cur.nature.framework.mvc.crud.CrudDao;
import cur.nature.tinyorm.core.bean.PageBean;
import cur.nature.tinyorm.core.template.DefaultJdbcTemplate;
import cur.tool.model.po.Admin_DictPO;
import cur.tool.model.vo.Admin_DictVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 * 通用字典表 Dao
 * 作者：Auto Generator By wujian
 * 生成日期：2023-07-09 16:05:31
 */
@Component
@DependsOn(DefaultJdbcTemplate.TEMPLATE)
public class Admin_DictDao extends CrudDao<Admin_DictPO, Admin_DictVO> {
    public Admin_DictDao(@Qualifier(DefaultJdbcTemplate.TEMPLATE) DefaultJdbcTemplate template) {
        super(Admin_DictPO.class, Admin_DictVO.class, template);
    }

    public PageBean<Admin_DictVO> list(Admin_DictVO.list_Param param) throws Exception {
        StringBuilder condition = new StringBuilder(" 1=1 ");
        if (StringUtil.isNotEmpty(param.getKeyword())) {
            condition.append(" and a.code like '" + param.getKeyword() + "%' ");
        }
        String sql = "select " + this.cols() + " from " + tableName() + " a " + " where " + condition + " order by id desc";
        PageBean<Admin_DictVO> list = queryForPage(sql, param.buildPage(),
                null, Admin_DictVO.class);
        return list;
    }

}

